package com.exam.system.util;

import lombok.Data;

/**
 * 返回结果
 */
@Data
public class AjaxResult {
    private boolean success;
    private String message;
    private Integer code; //状态码

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setCode(200);
        return ajaxResult;
    }

    public static AjaxResult success(String message){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setCode(200);
        ajaxResult.setMessage(message);
        return ajaxResult;
    }

    public static AjaxResult fail(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setCode(400);
        return ajaxResult;
    }

    public static AjaxResult fail(String message){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setCode(400);
        ajaxResult.setMessage(message);
        return ajaxResult;
    }
}
